/**
 * Copyright (c) 2006-2007 Jinyi.lu
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of GNU LGPL license by gun.org
 * which accompanies this distribution, and is available at
 * http://gnu.feld-it.at/copyleft/lesser.html
 * 
 * Project Homepage : http://code.google.com/p/demou
 * Source Code: svn checkout http://demou.googlecode.com/svn/trunk/ demou
 * Mailing list : jinyi.lu@gmail.com
 *                stonelu@126.com
 *
 *  
 * Contributors:
 *     JinYi.Lu - initial API and implementation
 */
package cn.tworen.demou.remoting;

/**
 * Created on  2007-2-5
 *
 * Title       : Body.java
 * Description : 
 * 
 * @author     : LuJinYi
 * @version    : 1.0
 * @Date       : 2007-2-5
 * History     : 
 * 
 */
public class Body<T> {
	private String targetURI = "";
	private String responseURI = "";
	private T value = null;
	public Body() {
		
	}
	public Body(String targetURI, String responseURI, T value) {
		this.targetURI = targetURI;
		this.responseURI = responseURI;
		this.value = value;
	}
	/**
	 * @hibernate.property
	 * @return Returns the targetURI.
	 */
	public String getTargetURI() {
		return targetURI;
	}
	/**
	 * @param targetURI the targetURI to set
	 */
	public void setTargetURI(String targetURI) {
		if (targetURI == null) {
			this.targetURI = "";
		} else{
			this.targetURI = targetURI;
		}
	}
	/**
	 * @hibernate.property
	 * @return Returns the responseURI.
	 */
	public String getResponseURI() {
		return responseURI;
	}
	/**
	 * @param responseURI the responseURI to set
	 */
	public void setResponseURI(String responseURI) {
		if (responseURI == null) {
			this.responseURI = "";
		} else {
			this.responseURI = responseURI;
		}
	}
	/**
	 * @hibernate.property
	 * @return Returns the value.
	 */
	public T getValue() {
		return value;
	}
	/**
	 * @param value the value to set
	 */
	public void setValue(T value) {
		this.value = value;
	}
	public void setReplyName(String methodName) {
        if(this.targetURI.endsWith("/onStatus") || this.targetURI.endsWith("/onResult"))
        	this.targetURI = this.targetURI.substring(0, targetURI.lastIndexOf("/"));
        this.targetURI = this.targetURI + methodName;
	}
}
